#!/usr/bin/python
# -*- coding: utf-8 -*-
from bottle import *
import sae

#from google.appengine.ext.webapp.util import run_wsgi_app

#from os.path import abspath, dirname, join
#app_root = dirname(__file__)

app = Bottle()

@app.route('/api/<ct>', method='OPTIONS')
def CORSupport(ct):
    response.set_header('Access-Control-Allow-Origin', '*')
    response.set_header('Access-Control-Allow-Headers', 'x-requested-with')

@app.route('/api/<ct>')
def api(ct):
    echo = {'ct':int(ct)+1, 'act':'/%s'%ct }
    print int(ct)+1
    response.set_header('Access-Control-Allow-Origin', '*')
    response.set_header('Access-Control-Allow-Headers', 'x-requested-with')
    response.set_header('Content-Type','application/json; charset=utf-8')
    return echo

@app.route('/api')
def api_readme():
    return '''JSON as:{
        act: "/1",
        ct: 2
        }
    '''
#@view('404.html')
@app.route('/')
def index():
    return "testing Angular for href plus ng-click"

@app.route('/favicon.ico')
def favicon():
    abort(204)

@app.route('/static/<path:path>')
def server_static(path):
    return static_file(path, root='static')
 





application = sae.create_wsgi_app(app)
